--TEST--
resource MySQLndUhConnection::connect(resource $res, string $host, string $user, string $passwd, string $db, string $db, string $port, string $socket, int $mysql_flags)
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
	require_once('config.inc');

	class proxy extends MySQLndUhConnection {
		public function connect($res, $host, $user, $passwd, $db, $port, $socket, $mysql_flags) {
			printf("%s(%s)\n", __METHOD__, var_export(func_get_args(), true));
			/* CAUTION: Userland must call the default implementation. If not, you'll get a crash */
			return parent::connect($res, $host, $user, $passwd, $db, $port, $socket, $mysql_flags);
		}
	}

	class proxy2 extends MySQLndUhConnection {
		public function init($res) {
			printf("%s(%s)\n", __METHOD__, var_export($res, true));
			/* CAUTION: Userland must call the default implementation. If not, you'll get a crash */
			parent::init($res);
		}
		public function connect($res, $host, $user, $passwd, $db, $port, $socket, $mysql_flags) {
			printf("%s(%s)\n", __METHOD__, var_export(func_get_args(), true));
			$user = "foo";
			/* CAUTION: Userland must call the default implementation. If not, you'll get a crash */
			return parent::connect($res, $host, $user, $passwd, $db, $port, $socket, $mysql_flags);
		}
	}

	$conn = mysqlnd_uh_test\connect::mysqli();
	mysqlnd_uh_test\query_test::mysqli($conn);

	mysqlnd_uh_set_connection_proxy(new proxy());

	$conn = mysqlnd_uh_test\connect::mysqli();
	mysqlnd_uh_test\query_test::mysqli($conn);

	$mysqli = mysqli_init();
	var_dump(mysqlnd_uh_set_connection_proxy(new proxy2(), $mysqli));
	var_dump($mysqli->connect(MYSQLND_UH_TEST_MYSQL_HOST, MYSQLND_UH_TEST_MYSQL_USER, MYSQLND_UH_TEST_MYSQL_PASSWD, MYSQLND_UH_TEST_MYSQL_DB, MYSQLND_UH_TEST_MYSQL_PORT, MYSQLND_UH_TEST_MYSQL_SOCKET));
	mysqlnd_uh_test\query_test::mysqli($mysqli);

	print "done!";
?>
--EXPECTF--
proxy::connect(array (
  0 => NULL,
  1 => %s,
  2 => %s,
  3 => %s,
  4 => %s,
  5 => %d,
  6 => %s,
  7 => %d,
))
bool(true)
proxy2::connect(array (
  0 => NULL,
  1 => %s,
  2 => %s,
  3 => %s,
  4 => %s,
  5 => %d,
  6 => %s,
  7 => %d,
))

Warning: mysqli::connect(): (%s/%d): Access denied for user 'foo'@%s (using password: YES) in %s on line %d
bool(false)

Warning: mysqli::query(): invalid object or resource mysqli
 in %s on line %d
[000]  - query execution failed
done!